package com.buka.communicate.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.buka.communicate.R;
import com.buka.communicate.adapter.TagAdapter;

import net.neiquan.applibrary.base.BaseActivity;
import net.neiquan.applibrary.flowtag.FlowTagLayout;
import net.neiquan.applibrary.flowtag.OnTagSelectListener;

import org.haitao.common.utils.AppLog;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/11/13 0013.
 */

public class ImpressTagActivity extends BaseActivity {
    @InjectView(R.id.tagFlowLayout)
    FlowTagLayout tagFlowLayout;
    @InjectView(R.id.diyTagTv)
    TextView diyTagTv;
    private TagAdapter<String> adapter;

    @Override
    public int getRootViewId() {
        return R.layout.activity_impress_tag;
    }

    @Override
    public void setViews() {
        getNextTv().setTextColor(getResources().getColor(R.color.app_color));
        setNextTv("保存");
        setTitleTv("添加标签");
    }

    @Override
    public void initData() {
        initTagLayout();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.inject(this);
    }

    @OnClick(R.id.diyTagTv)
    public void onViewClicked() {
    }

    private void initTagLayout() {
        List<String> strings = new ArrayList<>();
        strings.add("萌萌哒");
        strings.add("女汉子");
        strings.add("强迫症");
        strings.add("拖延症");
        strings.add("极品吃货");
        strings.add("叫我逗比");
        strings.add("双重人格");
        strings.add("喜欢简单");
        strings.add("敢爱敢恨");
        strings.add("选择恐惧症");
        strings.add("宅");
        strings.add("女友永远是对的");
        strings.add("文艺");
        strings.add("大叔控");
        strings.add("马甲线");
        strings.add("长发及腰");
        strings.add("安静");
        strings.add("热血");
        tagFlowLayout.setTagCheckedMode(FlowTagLayout.FLOW_TAG_CHECKED_SINGLE);
        adapter = new TagAdapter<String>(this);
        tagFlowLayout.setAdapter(adapter);
        adapter.clearAndAddAll(strings);
        tagFlowLayout.setOnTagSelectListener(new OnTagSelectListener() {
            @Override
            public void onItemSelect(FlowTagLayout parent, List<Integer> selectedList) {
//                for (int i = 0; i < selectedList.size(); i++) {
//                    AppLog.e("==========setOnTagSelectListener===========" + selectedList.get(i));
//                    Search data = ((Search) parent.getAdapter().getItem(selectedList.get(i)));
//                    Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
//                    intent.putExtra("search", data.getTitle());
//                    startActivity(intent);
//                }
            }
        });
    }
}
